package com.wuyu.mini.dubbo.cluster;

import java.util.List;

/**
 * 负载均衡抽象实现
 * @author wuyu
 */
public abstract class AbstractLoadBalance implements LoadBalance {

    /**
     * 选择服务提供者
     * @param providers
     * @return
     */
    public String select(List<String> providers) {
        if (providers == null || providers.size() == 0) {
            return null;
        }
        if (providers.size() == 1){
            return providers.get(0);
        }
        return doSelect(providers);
    }

    public abstract String doSelect(List<String> providers);
}
